hysop.core.memory.buffer module

class hysop.core.memory.buffer.Buffer(size, **kwds)[source]

Bases: object

Base class for releasable buffers. A buffer should just offer a release method to be compatible with allocators.

Host buffers are numpy buffers. Cuda and OpenCl buffers are the one provided by pycuda and pyopencl.

Buffers should be obtained through allocators or memory pools.

abstract aligned_view(alignment, size=None)[source]

Return a view of this buffer with an offset such that the returned buffer is now aligned on min_alignment and has now given size.

property buf
classmethod from_int_ptr(int_ptr_value, **kargs)[source]

Constructs a pyopencl handle from a C-level pointer (given as the integer int_ptr_value). If the previous owner of the object owns the handle and will not release it, on can set retain to False, to effectively transfer ownership. Setting retain to True should increase an implementation specific reference counter. The buffer will be freed when buffer reference counter is 0.

get_buffer()[source]
get_size()[source]
abstract release()[source]

Release this buffer (decrease internal implementation defined reference counter).

property size
class hysop.core.memory.buffer.PooledBuffer(pool, buf, alloc_sz, size, alignment, **kwds)[source]

Bases: Buffer

Memory pool allocated buffer wrapper.

Create a memory pool wrapped buffer. Input buffer buf was allocated by given pool with real size alloc_sz. Buffer is resized and aligned to given size and alignment. On destruction, buffer will be given back to the pool.

aligned_view(alignment, size=None)[source]

Return a view of this buffer with an offset such that the returned buffer is now aligned on min_alignment and has now given size.

property buf

Get wrapped buffer handle.

get_buf()[source]

Get wrapped buffer handle.

get_int_ptr()[source]

Get wrapped buffer handle pointer as an int.

get_pool()[source]

Get pool that allocated this buffer.

property int_ptr

Get wrapped buffer handle pointer as an int.

property pool

Get pool that allocated this buffer.

release()[source]

Tells the memory pool that this buffer has no longer to be held.